package com.gdk.ksoft.assembly.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.gdk.ksoft.R;
import com.gdk.ksoft.data.common.SystemData;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * Created by Mrper on 2014/11/22.
 * 客户位置记录对话框
 */
public class LocationRecorderDialog extends Dialog {

    @ViewInject(R.id.drecorder_location_txtCustomerName)private TextView txtCustomerName;//客户名称
    @ViewInject(R.id.drecorder_location_txtCustomerAddress)private TextView txtCustomerAddress;//客户地址
    @ViewInject(R.id.drecorder_location_txtCustomerLatLng)private TextView txtCustomerLatLng;//客户经纬度
    @ViewInject(R.id.drecorder_location_txtCustomerCancel)private TextView txtCustomerCancel;//取消
    @ViewInject(R.id.drecorder_location_txtCustomerOK)private TextView txtCustomerOK;//确定操作

    /**
     *
     * @param context
     * @param customerName 客户名称
     * @param customerAddress 客户收货地址
     */
    public LocationRecorderDialog(Context context,String customerName,String customerAddress) {
        super(context,R.style.WindowDialogTheme);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        View rootView = View.inflate(context, R.layout.dialog_recorder_location, null);
        setContentView(rootView);
        ViewUtils.inject(this,rootView);
        txtCustomerName.setText(customerName);
        txtCustomerAddress.setText(customerAddress);
        if (SystemData.currentLocation != null)
            txtCustomerLatLng.setText(SystemData.currentLocation.getLatitude() + "(纬度) \n" + SystemData.currentLocation.getLongitude() + "(经度)");
        else
            txtCustomerLatLng.setText("不可用");
    }

    /**
     * 设置按钮的操作事件
     * @param listener
     */
    public void setOnPositiveNegitiveClick(View.OnClickListener listener){
        if(listener!=null) {
            txtCustomerCancel.setOnClickListener(listener);
            txtCustomerOK.setOnClickListener(listener);
        }
    }

}
